<?php
require_once "cli.php";
if (!class_exists('Facebook'))
{
    require_once 'facebook.php' ;
}
$sUrl = phpfox::getLib('url')->makeUrl('contactimporter.facebook');    
$aFbSetting = Phpfox::getService('contactimporter.setting')->getApiSetting('facebook');    
if ($aFbSetting == null)
{
    echo Phpfox::getPhrase('contactimporter.please_enter_your_facebook_api');
    exit;    
}
$aFbSetting['api_params'] = unserialize($aFbSetting['api_params']);
$oFacebook  = new FacebookSBYN(array(
    'appId'  => $aFbSetting['api_params']['appid'],
    'secret' => $aFbSetting['api_params']['secret'],
    'cookie' => true,
));
$session = $oFacebook->getSession();
$oFacebook->setSession($session);
echo "<script>opener.parent.location.href = '".$sUrl."';</script>";
echo "<script>self.close();</script>";
?>